package com.polaris.live.popup

import android.content.Context
import com.lxj.xpopup.core.BottomPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.PopupSelectImageBinding

/**
 * 选择相册还是相机半弹窗
 *
 * @author Created by 半仙 on 2023/9/27/027 17:46
 */
class SelectImagePopup(
    context: Context,
    private val onSelectIt: ((type: Int) -> Unit)) :
    BottomPopupView(context) {

    //1 = 相机 2 = 相册
    companion object {

        const val CAMERA = 1
        const val ALBUM = 2
    }

    private lateinit var mBinding: PopupSelectImageBinding

    override fun getImplLayoutId(): Int {
        return R.layout.popup_select_image
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = PopupSelectImageBinding.bind(popupImplView)

        mBinding.llSelectAlbum.setOnSingleClickListener {
            onSelectIt.invoke(ALBUM)
            dismiss()
        }
        mBinding.llSelectCamera.setOnSingleClickListener {
            onSelectIt.invoke(CAMERA)
            dismiss()
        }

        mBinding.icClose.setOnSingleClickListener {
            dismiss()
        }
    }
}